add_library(debugging debug.c)

# utility component
add_library(utils utils.c ${UTILS_EXTRA_SRCS})
target_link_libraries(utils ${GLIB2_LIBRARIES})

# async_queue component
add_library(async_queue async_queue.c)
set(ASYNC_QUEUE_EXTRA_LIBS ${GLIB2_LIBRARIES})
if (WIN32)
	list(APPEND ASYNC_QUEUE_EXTRA_LIBS ${CMAKE_THREAD_LIBS_INIT})
else()
	list(APPEND ASYNC_QUEUE_EXTRA_LIBS rt)
endif()
target_link_libraries(async_queue ${ASYNC_QUEUE_EXTRA_LIBS})

# fsnotify component
add_library(fsnotify fsnotify.c ${FSNOTIFY_EXTRA_SRCS})
if (WIN32)
	list(APPEND FSNOTIFY_EXTRA_LIBS ${CMAKE_THREAD_LIBS_INIT})
endif()
list(APPEND FSNOTIFY_EXTRA_LIBS ${GLIB2_LIBRARIES})
target_link_libraries(fsnotify ${FSNOTIFY_EXTRA_LIBS})

if (NOT WIN32) # can't port to windows yet
find_package(LibMySQLD)
include_directories(${LibMySQLD_INCLUDE_DIR})
link_directories(${LibMySQLD_LIBRARY_DIR})
add_library(syncup_db db/syncup_db.c)
target_link_libraries(syncup_db ${LibMySQLD_LIBRARIES} ${GLIB2_LIBRARIES})

include_directories(${SYNCUP_EXTRA_INCLUDE})
add_library(syncup syncup.c ${SYNCUP_EXTRA_SRCS})
set_source_files_properties(${SYNCUP_EXTRA_GEN_SRCS} PROPERTIES GENERATED 1)
add_dependencies(syncup ${SYNCUP_EXTRA_DEPENDS})
target_link_libraries(syncup
	async_queue
	usb_media
	fsnotify
	syncup_db
	utils
	${GLIB2_LIBRARIES}
	${SYNCUP_EXTRA_LIBS})

add_executable(sync-up main.c)
target_link_libraries(sync-up syncup)
endif()	

add_subdirectory(frontend)